import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:flutter/material.dart';

class TableItem {
  final String name;
  final String content;
  final String trailing;

  TableItem(this.name, this.content, this.trailing);
}

class NormalTable extends StatelessWidget {
  final TableItem header;
  final List<TableItem> items;

  NormalTable({Key key, this.header, this.items}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: getDp(24), vertical: getDp(20)),
      decoration: BoxDecoration(
        border: Border.all(
          color: aceWhiteGreyColor,
        ),
        borderRadius: BorderRadius.circular(getDp(5)),
      ),
      child: Column(
        children: [
          SizedBox(
            height: getDp(14),
          ),
          if (header != null)
            DefaultTextStyle(
              style: TextStyle(
                color: aceBlackColor,
                fontSize: getSp(16),
                fontWeight: FontWeight.w700,
                height: 22 / 16,
                fontFamily: "DinRoundPro",
              ),
              child: Padding(
                padding: EdgeInsets.symmetric(horizontal: getDp(10)),
                child: Row(
                  children: [
                    Expanded(child: Text(header.name)),
                    SizedBox(width: getDp(60), child: Text(header.content)),
                    SizedBox(width: getDp(60), child: Text(header.trailing))
                  ],
                ),
              ),
            ),
          AppSpaces.h15,
          AppSpaces.grayH05,
          AppSpaces.h15,
          DefaultTextStyle(
              style: TextStyle(
                color: aceBlackColor,
                fontSize: getSp(16),
                fontWeight: FontWeight.w400,
                height: 22 / 16,
                fontFamily: "DinRoundPro",
              ),
              child: Column(
                children: [
                  if (items != null)
                    ...items
                        .map((e) => Padding(
                              padding: EdgeInsets.only(
                                  left: getDp(10),
                                  right: getDp(10),
                                  bottom: getDp(15)),
                              child: Row(
                                children: [
                                  Expanded(child: Text(e.name)),
                                  SizedBox(
                                      width: getDp(60), child: Text(e.content)),
                                  SizedBox(
                                      width: getDp(60),
                                      child: Center(child: Text(e.trailing)))
                                ],
                              ),
                            ))
                        .toList(),
                  AppSpaces.h5,
                ],
              )),
        ],
      ),
    );
  }
}
